
//多级菜单定义
import charts from './routers/charts';
import editor from './routers/editor';
import setting from './routers/setting';


const defaultRouter = [
	{
		name: '首页',
		path: '/pages/index/index',
		icon: 'index' //阿里云矢量图复制svg代码，不要直接下载svg，否则无法修改颜色，放在static/svg下，修改文件名为icon的值，就可以使用了
	},
  {
		name: '学员管理',
		path: '/pages/index/index',
		icon: 'user' 
	},
  {
		name: '课程设置',
		path: '/pages/index/index',
		icon: '111'
	},
  {
		name: '订单管理',
		path: '/pages/index/index',
		icon: 'order'
	},
  {
		name: '收费明细',
		path: '/pages/index/index',
		icon: 'price'
	},
  {
		name: '优惠活动设置',
		path: '/pages/index/index',
		icon: 'huodong'
	},
  {
		name: '机构信息',
		path: '/pages/index/index',
		icon: 'org'
	}
	// {
	// 	name: '地图',
	// 	path: '/pages/map/map',
	// 	icon: 'map'
	// },
	// ...setting,
	// ...charts,
	//...editor
];

// 给tree添加index，并且添加面包屑title
const addMenuTreeIndex = (menuTree, parentIndex:string ='', parentTitle:string = '')=> {
  let menuArray = [];
  menuTree.forEach((menu, index:string) => {
    let currentIndex = parentIndex ? `${parentIndex}-${index}` : `${index}`;
    let currentTitle = parentTitle ? `${parentTitle} / ${menu.name}` : menu.name;
    let menuItem = {
      index: currentIndex,
      title: currentTitle,
	  name: menu.name,
      icon: menu.icon,
      path: menu.path
    };
    if (menu.children && menu.children.length > 0) {
      menuItem.children = addMenuTreeIndex(menu.children, currentIndex, currentTitle);
    }
    menuArray.push(menuItem);
  });
  return menuArray;
}
export default addMenuTreeIndex(defaultRouter);
